<template>
  <n-spin :show="loading">
    <template v-for="(item, index) in tableData" :key="index">
      <n-card :title="'数据表：' + item.tName" style="margin-bottom: 10px">
        <n-data-table
          :columns="columns"
          :data="item.column"
          default-expand-all
          style="margin-bottom: 20px; width: 100%"
          :scroll-x="900"
        />
      </n-card>
    </template>
  </n-spin>
</template>

<script setup lang="ts">
import { getArchiveTable } from "@/api/platform";
import { inject, onMounted, ref } from "vue";

const loading = ref(false);
const tableData = ref();
const columns = ref([
  {
    title: "名称",
    key: "columnName",
  },

  {
    title: "类型",
    key: "columnType",
  },

  {
    title: "是否主键",
    key: "columnIsKey",
    render: (row: any) => (row.columnIsKey ? "true" : "false"),
  },
  {
    title: "是否可为空",
    key: "columnIsNull",
    render: (row: any) => (row.columnType ? "true" : "false"),
  },
  {
    title: "备注",
    key: "columnComment",
  },
]);
onMounted(() => {
  loading.value = true;
  getArchiveTable()
    .then((res) => {
      tableData.value = res.data;
      loading.value = false;
    })
    .catch((err) => {
      loading.value = false;
    });
});
</script>
